<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>后台登录</title>
    <link href="background/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <link href="login/css/sweetalert.css" rel="stylesheet" type="text/css">
    <link href="background/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />

    <link href="login/css/style.css" rel='stylesheet' type='text/css' />

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script type="application/x-javascript">
        addEventListener("load", function() {
            setTimeout(hideURLbar, 0);
        }, false);

        function hideURLbar() {
            window.scrollTo(0, 1);
        }
    </script>
</head>
<body>
<!-----start-main---->
<div class="main">
    <div class="login-form">
        <h1>后台登录</h1>
        <div class="head">
            <img src="login/images/user.png" alt="" />
        </div>
        <form>
            <input type="text" class="text" id="name" placeholder="USERNAME"  >
            <input type="password" placeholder="Password" id="pwd" >
            <div class="submit">
                <button type="button" class="btn btn-primary btn-block  btn-flat" onclick="login()" >登录</button>
                <span style="color: #ff0000;font-weight: bold" th:text="${msg}"></span>
            </div>
        </form>
    </div>

</div>
<!-----//end-main---->


<script src="background/js/jquery.min.js"></script>
<script src="common/js/sweetalert.min.js"></script>
<script type="text/javascript">

    function login(){
        var name=$('#name').val();
        var pwd=$('#pwd').val();
        console.log(name);
        console.log(pwd);
        $.ajax({
            type: 'POST',
            data:{name:name,pwd:pwd},
            url:'dologin',
            dataType:'json',
            success: function (result) {
                console.log(result);
                if (result.code==200) {
                    window.location.href = "dashboard";
                } else {
                    console.log("sd");
                    //alert(result.message);
                    swal(result.message, {
                        icon: "error",
                    });
                }
                ;
            },
            error: function () {
                console.log("sasd");
                //alert("操作失败");
                swal("操作失败", {
                    icon: "error",
                });
            }


        })
    }
</script>
</body>
</html>